package com.yl.ydk.ui.fragment

import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.yl.ydk.R
import com.yl.ydk.base.BaseFragment
import com.yl.ydk.presenter.contract.HealthyVideoLisetFragmentContract
import com.yl.ydk.presenter.impl.HealthyVideoLisetFragmentImpl
import com.blankj.utilcode.utils.ToastUtils
import kotlinx.android.synthetic.main.fragment_healthy_videolist.*

class HealthyVideoLisetFragment : BaseFragment(), HealthyVideoLisetFragmentContract.View {

    private val mPresenter = HealthyVideoLisetFragmentImpl()
    private var title: String? = null
    private var category_id: Int? = null

    companion object {
        fun getInstance(title: String, category_id: Int): HealthyVideoLisetFragment {
            val sf = HealthyVideoLisetFragment()
            sf.title = title
            sf.category_id = category_id
            return sf
        }
    }

    override fun getLayoutResId(): Int = R.layout.fragment_healthy_videolist

    override fun attachView() {
        mPresenter.attachView(this)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        activity?.let {
            mPresenter.getVideoList(it, "title", title, "category_id", category_id.toString())
        }
    }

    override fun getRecyclerView(): RecyclerView?  = rvHealthyVideo

    override fun showError(message: String?) {
        ToastUtils.showLongToastSafe(message)
    }

}